﻿using System;

namespace MathService
{
    public partial struct Complex
    {
        /* -------------------------------------------------------------------------------------------- */

        public static class Trigonomerty
        {
            public static Complex Sin(Complex z)
            {
                var re = z.Re;
                var im = z.Im;
                if(Math.Abs(im) < double.Epsilon) return new Complex(Math.Sin(re));
                var eb = Math.Exp(im);
                var eb_inv = 1 / eb;

                return new Complex(.5 * Math.Sin(re) * (eb_inv + eb), .5 * Math.Cos(re) * (eb - eb_inv));
            }

            public static Complex Cos(Complex z)
            {
                var re = z.Re;
                var im = z.Im;
                if(Math.Abs(im) < double.Epsilon) return new Complex(Math.Cos(re));
                var eb = Math.Exp(im);
                var eb_inv = 1 / eb;

                return new Complex(.5 * Math.Cos(re) * (eb_inv + eb), .5 * Math.Sin(re) * (eb_inv - eb));
            }

            public static Complex Tg(Complex z)
            {
                var re = z.Re;
                var im = z.Im;
                if(Math.Abs(im) < double.Epsilon) return new Complex(Math.Sin(re) / Math.Cos(re));

                throw new NotImplementedException();
            }

            public static class Hyperbolic
            {
                public static Complex Sh(Complex z)
                {
                    throw new NotImplementedException();
                }

                public static Complex Ch(Complex z)
                {
                    throw new NotImplementedException();
                }
            }
        }

    }
}
